<template>
  <div class="dashboard-editor-container">
    <!-- <github-corner class="github-corner" /> -->

    <div style="font-weight: bold;font-size: 20px;color: #666;">欢迎访问 德宏师范高等专科学校招聘系统 管理后台</div>
    <panel-group  />
    <el-row>
      <el-table
        :data="tableData"
        border
        fit
        style="width: 100%;"
        align="center">
        <el-table-column
          prop="post_code"
          label="岗位"
          align="center"
          >
        </el-table-column>
        <el-table-column
          prop="post_code1"
          label="专业"
          align="center"
          width="280">
        </el-table-column>
        <el-table-column
          prop="post_code_count"
          label="报名人数"
          align="center"
          width="230">
        </el-table-column>
        <el-table-column
          prop="success_list"
          label="初审通过"
          align="center"
          width="230">
        </el-table-column>
        <el-table-column
          prop="error_list"
          label="审核不通过"
          align="center"
          width="230">
        </el-table-column>
     </el-table>
    </el-row>
    <!-- <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
      <line-chart :chart-data="lineChartData" />
    </el-row>  -->

  </div>
</template>

<script>
// eslint-disable-next-line
/* eslint-disable */
  import GithubCorner from '@/components/GithubCorner'
  import PanelGroup from './components/PanelGroup'
  //import LineChart from './components/LineChart'
  import { enrollInfo,getPlan } from '../../../api/user'
   const lineChartData = {
    newVisitis: {
      expectedData: [100, 120, 161, 134, 105, 160, 165],
      actualData: [120, 82, 91, 154, 162, 140, 145]
    },
    messages: {
      expectedData: [200, 192, 120, 144, 160, 130, 140],
      actualData: [180, 160, 151, 106, 145, 150, 130]
    },
    purchases: {
      expectedData: [80, 100, 121, 104, 105, 90, 100],
      actualData: [120, 90, 100, 138, 142, 130, 130]
    },
    shoppings: {
      expectedData: [130, 140, 141, 142, 145, 150, 160],
      actualData: [120, 82, 91, 154, 162, 140, 130]
    }
  } 

  export default {
    name: 'DashboardAdmin',
    components: {
      GithubCorner,
      PanelGroup,
      //LineChart
    },
    data() {
      return {
        lineChartData: lineChartData.newVisitis,
        tableData:[],
        post_code_options:[],
      }
    },
    created() {
      this.enroll_count()
      
      //console.log(this.tableData)
    },
    /* computed:{
      
      
    }, */
    methods: {
      /* handleSetLineChartData(type) {
        this.lineChartData = lineChartData[type]
      }, */
      enroll_count(){
        //this.loading = true
        getPlan().then(response => {
        
        
        this.post_code_options = response.data
        console.log(this.post_code_options)
        this.post_code_options.forEach((item, index)=>{
            console.log(item)
            enrollInfo(item.postCode).then(response => {
            //console.log(response)
          
            const { enroll_num, enroll_succes, enroll_error} = response.data
            this.tableData.push({post_code:item.postCode,post_code1:item.major,post_code_count:enroll_num[0].count,success_list:enroll_succes[0].count,error_list:enroll_error[0].count})
          })
        
     })
        //this.tableData.push({post_code:item.value,post_code1:item.label,post_code_count:enroll_num[0].count,success_list:enroll_succes[0].count,error_list:enroll_error[0].count})
      })
     
        
     /* this.tableData.sort(function(a,b){
              var x = a['post_code'].slice(6,8);
              console.log("11"+a['post_code'])
              var y = b['post_code'].slice(6,8);
              return ((y<x)?-1:(x>y)?1:0)   //从小到大排序
      }) */
        

      },
     
    }
  }
</script>

<style lang="scss" scoped>
  .dashboard-editor-container {
    padding: 32px;
    background-color: rgb(240, 242, 245);
    position: relative;

    .github-corner {
      position: absolute;
      top: 0px;
      border: 0;
      right: 0;
    }

    .chart-wrapper {
      background: #fff;
      padding: 16px 16px 0;
      margin-bottom: 32px;
    }
  }

  @media (max-width: 1024px) {
    .chart-wrapper {
      padding: 8px;
    }
  }
</style>
